<html>
<head><meta charset="utf-8"><title>eddyb - niko sync · t-compiler/wg-mir-opt · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/index.html">t-compiler/wg-mir-opt</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html">eddyb - niko sync</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="174879494"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174879494" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174879494">(Sep 04 2019 at 13:08)</a>:</h4>
<p>So I've been chatting a bit with <span class="user-mention" data-user-id="119009">@eddyb</span> about MIR optimizations and I realized we should be holding that conversation here.</p>



<a name="174879560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174879560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174879560">(Sep 04 2019 at 13:09)</a>:</h4>
<p>The context is that there have been a lot of complaints about intermediate memcpy's being a particular kind of poor codegen, particularly coming from the stylo/servo projects, and I'm trying to drill down to what the specific steps are for us to improve that situation.</p>



<a name="174879647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174879647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174879647">(Sep 04 2019 at 13:10)</a>:</h4>
<p>I've also talked to a few people who've been waiting for these optimizations for years</p>



<a name="174879662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174879662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174879662">(Sep 04 2019 at 13:10)</a>:</h4>
<p>OK, so so far we identified that we need to improve MIR debuginfo -- and <span class="user-mention" data-user-id="119009">@eddyb</span> has a draft PR that tries to introduce a new representation based on <code>(name, scope, place)</code> tuples -- but that work needs to be completed. This would enable us to track the name of user-given things through optimizations.</p>



<a name="174879666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174879666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174879666">(Sep 04 2019 at 13:10)</a>:</h4>
<p>apologies notwithstanding, it would be good to actually get them in</p>



<a name="174879670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174879670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174879670">(Sep 04 2019 at 13:10)</a>:</h4>
<p>You were then talking about SROA?</p>



<a name="174879685"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174879685" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174879685">(Sep 04 2019 at 13:10)</a>:</h4>
<p>Say a bit more about that</p>



<a name="174879713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174879713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174879713">(Sep 04 2019 at 13:11)</a>:</h4>
<p>I guess by SROA you mean taking a MIR literal like <code>Foo { ... }</code> and converting it into individual wri.... oh, no, you mean promoting the fields of a stack-allocated literal to distinct variables, of course</p>



<a name="174879721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174879721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174879721">(Sep 04 2019 at 13:11)</a>:</h4>
<p>first off, the tuple is not as clear as it could be. the printed syntax is:</p>
<div class="codehilite"><pre><span></span><span class="n">scope</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">name</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">place</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="174879779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174879779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174879779">(Sep 04 2019 at 13:12)</a>:</h4>
<p>ok</p>



<a name="174879812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174879812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174879812">(Sep 04 2019 at 13:12)</a>:</h4>
<p>I'm not sure which is clearer, but that makes sense</p>



<a name="174879898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174879898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174879898">(Sep 04 2019 at 13:13)</a>:</h4>
<blockquote>
<p>I've also talked to a few people who've been waiting for these optimizations for years</p>
</blockquote>
<p>it would be really good to get specific examples -- I think maybe you mentioned you have some floating around?</p>



<a name="174879902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174879902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174879902">(Sep 04 2019 at 13:13)</a>:</h4>
<p>the difference with SROA is that you are replacing <code>local.x.y.z</code> with <code>local_x_y_z</code> so if you want debuggers to still show a composite image of <code>local</code>, from all of the locals it has been split in</p>



<a name="174879918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174879918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174879918">(Sep 04 2019 at 13:13)</a>:</h4>
<p>one of my fears -- I consider it basically a certainty -- is that we'll do this work and then find it's not helping the <em>actual</em> example programs</p>



<a name="174879923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174879923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174879923">(Sep 04 2019 at 13:13)</a>:</h4>
<p>you also need projections (although more limited) on the LHS</p>



<a name="174879928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174879928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174879928">(Sep 04 2019 at 13:13)</a>:</h4>
<p>(which just means we'll have to figure out what the next blocker is)</p>



<a name="174879938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174879938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174879938">(Sep 04 2019 at 13:13)</a>:</h4>
<p>I have examples  I was testing on, and which were working :D</p>



<a name="174879964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174879964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174879964">(Sep 04 2019 at 13:13)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">Newtype</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">(</span><span class="n">T</span><span class="p">);</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">Huge</span><span class="p">(</span><span class="kt">u64</span><span class="p">);</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">Newtype</span><span class="o">&lt;</span><span class="n">Huge</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">Huge</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="n">drop</span><span class="p">(</span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">x</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="n">Newtype</span><span class="p">(</span><span class="n">Newtype</span><span class="p">(</span><span class="n">x</span><span class="p">)).</span><span class="mi">0</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="174880022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880022">(Sep 04 2019 at 13:14)</a>:</h4>
<p>I think this is the most simplified version</p>



<a name="174880050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880050">(Sep 04 2019 at 13:14)</a>:</h4>
<p>(maybe we can collect those examples at some point in the <a href="https://github.com/rust-lang/compiler-team/tree/master/content/working-groups/mir-opt" target="_blank" title="https://github.com/rust-lang/compiler-team/tree/master/content/working-groups/mir-opt">mir-opt working group directory</a>)</p>



<a name="174880071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880071">(Sep 04 2019 at 13:14)</a>:</h4>
<p>yeah, I think what would prob be good is (a) a reduced example and (b) a link to the original source and benchmark if possible</p>



<a name="174880074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880074">(Sep 04 2019 at 13:14)</a>:</h4>
<p>but that's great</p>



<a name="174880076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880076">(Sep 04 2019 at 13:15)</a>:</h4>
<p>I have presented some of these before, so I guess that means they never got collected :(</p>



<a name="174880089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880089">(Sep 04 2019 at 13:15)</a>:</h4>
<p>not afaik</p>



<a name="174880095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880095">(Sep 04 2019 at 13:15)</a>:</h4>
<p>I'd love to be wrong</p>



<a name="174880117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880117">(Sep 04 2019 at 13:15)</a>:</h4>
<p>there's the docs from the all hands that had at least some of these with annotations?</p>



<a name="174880122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880122">(Sep 04 2019 at 13:15)</a>:</h4>
<blockquote>
<p>the difference with SROA is that you are replacing <code>local.x.y.z</code> with <code>local_x_y_z</code> so if you want debuggers to still show a composite image of <code>local</code>, from all of the locals it has been split in</p>
</blockquote>
<p>how is this represented in your proposed debuginfo?</p>



<a name="174880132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880132">(Sep 04 2019 at 13:15)</a>:</h4>
<p>yeah! I forgot about those</p>



<a name="174880149"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880149" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880149">(Sep 04 2019 at 13:16)</a>:</h4>
<p>so that's what I was getting to, it needs extending with:</p>
<div class="codehilite"><pre><span></span><span class="n">scope</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">name</span><span class="w"> </span><span class="p">(.</span><span class="n">field</span><span class="p">)</span><span class="o">*</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">place</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="174880234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880234">(Sep 04 2019 at 13:16)</a>:</h4>
<blockquote>
<p>there's the docs from the all hands that had at least some of these with annotations?</p>
</blockquote>
<p>I guess you mean <a href="https://paper.dropbox.com/doc/Topic-MIR-2.0-and-MIR-Optimizations--AWnIuLeFMVhIFyWf7XyyquyDAg-BwHR7kOhxDwL6vuAUoSTQ" target="_blank" title="https://paper.dropbox.com/doc/Topic-MIR-2.0-and-MIR-Optimizations--AWnIuLeFMVhIFyWf7XyyquyDAg-BwHR7kOhxDwL6vuAUoSTQ">this MIR 2.0 dropbox paper</a></p>



<a name="174880241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880241">(Sep 04 2019 at 13:16)</a>:</h4>
<p>the codegen for this is easy once MIR variable debuginfo is implemented, since you just need to use the "slicing" feature of DWARF (which IIRC LLVM exposes)</p>



<a name="174880268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880268">(Sep 04 2019 at 13:17)</a>:</h4>
<blockquote>
<p>so that's what I was getting to, it needs extending with:</p>
</blockquote>
<p>ok, that makes sense</p>



<a name="174880269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880269">(Sep 04 2019 at 13:17)</a>:</h4>
<p>in fact, I think LLVM itself does this in its own SROA (lol)</p>



<a name="174880290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880290">(Sep 04 2019 at 13:17)</a>:</h4>
<p>technically NRVO only depends on MIR var debuginfo</p>



<a name="174880302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880302">(Sep 04 2019 at 13:17)</a>:</h4>
<p>while SROA requires that extension</p>



<a name="174880310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880310">(Sep 04 2019 at 13:17)</a>:</h4>
<p>OK, so, maybe we can consider that a distinct step? i.e., land the debuginfo you described before, then extract with more complex names?</p>



<a name="174880370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880370">(Sep 04 2019 at 13:18)</a>:</h4>
<p>but we need both optimizations for most of the interesting cases (SROA runs first, to strength-reduce locals for NRVO)</p>



<a name="174880382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880382">(Sep 04 2019 at 13:18)</a>:</h4>
<p>yupp!</p>



<a name="174880389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880389">(Sep 04 2019 at 13:18)</a>:</h4>
<p>that has been the plan for like a year</p>



<a name="174880393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880393">(Sep 04 2019 at 13:18)</a>:</h4>
<p>it just hasn't happened for reasons</p>



<a name="174880399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880399">(Sep 04 2019 at 13:18)</a>:</h4>
<p>the PR is <a href="https://github.com/rust-lang/rust/pull/56231" target="_blank" title="https://github.com/rust-lang/rust/pull/56231">https://github.com/rust-lang/rust/pull/56231</a></p>



<a name="174880452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880452">(Sep 04 2019 at 13:19)</a>:</h4>
<p>OK</p>



<a name="174880470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880470">(Sep 04 2019 at 13:19)</a>:</h4>
<p>I decided today that the best way forward is to actually introduce the representation in that PR in <code>rustc_codegen_ssa</code> alone</p>



<a name="174880492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880492">(Sep 04 2019 at 13:19)</a>:</h4>
<p>and refactor the mess that is MIR codegen debuginfo interactions</p>



<a name="174880506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880506">(Sep 04 2019 at 13:19)</a>:</h4>
<p>and <em>then</em> do that PR (which lets optimizations preserve debuginfo)</p>



<a name="174880513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880513">(Sep 04 2019 at 13:19)</a>:</h4>
<p>so that would mean starting over (for now, at least)</p>



<a name="174880516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880516">(Sep 04 2019 at 13:19)</a>:</h4>
<p>yeah</p>



<a name="174880604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880604">(Sep 04 2019 at 13:20)</a>:</h4>
<p>ok, so once debug info work lands, what blocks us from doing the SROA optimization?</p>



<a name="174880605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880605">(Sep 04 2019 at 13:20)</a>:</h4>
<p>well, I have never implemented the codegen bits</p>



<a name="174880614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880614">(Sep 04 2019 at 13:20)</a>:</h4>
<p>right, I just mean that it'd be a fresh PR</p>



<a name="174880618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880618">(Sep 04 2019 at 13:20)</a>:</h4>
<p>starting from master</p>



<a name="174880632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880632">(Sep 04 2019 at 13:20)</a>:</h4>
<p>maybe stealing bits from the other, I don't know</p>



<a name="174880658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880658">(Sep 04 2019 at 13:21)</a>:</h4>
<p>nothing blocks us, the SROA PR has been around for even longer</p>



<a name="174880684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880684">(Sep 04 2019 at 13:21)</a>:</h4>
<p>one thing I can imagine</p>



<a name="174880686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880686">(Sep 04 2019 at 13:21)</a>:</h4>
<p>well, we can land the PR</p>



<a name="174880706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880706">(Sep 04 2019 at 13:21)</a>:</h4>
<p>but what might block us from  <em>enabling it on stable</em> is the lack of any performance monitoring story for our generated code</p>



<a name="174880708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880708">(Sep 04 2019 at 13:21)</a>:</h4>
<p>NRVO has some philosophical (in the absence of a proof assistant) and performance concerns</p>



<a name="174880747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880747">(Sep 04 2019 at 13:21)</a>:</h4>
<blockquote>
<p>nothing blocks us, the SROA PR has been around for even longer</p>
</blockquote>
<p>link?</p>



<a name="174880803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880803">(Sep 04 2019 at 13:22)</a>:</h4>
<p>also the work <span class="user-mention" data-user-id="116883">@tmandry</span> has been doing with generators has highlighted a few things</p>



<a name="174880811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880811">(Sep 04 2019 at 13:22)</a>:</h4>
<p>about the analysis I was doing for NRVO</p>



<a name="174880831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880831">(Sep 04 2019 at 13:22)</a>:</h4>
<p>ok, so NRVO would be kind of a "next step" after SROA?</p>



<a name="174880840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880840">(Sep 04 2019 at 13:22)</a>:</h4>
<p>and nowadays I think I'd favor implementing several analyses and cross-checking them via crater (if only that ran faster...)</p>



<a name="174880882"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880882" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880882">(Sep 04 2019 at 13:23)</a>:</h4>
<p>yeah, SROA is an easy decision IMO, and we could right away run constprop after it</p>



<a name="174880914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880914">(Sep 04 2019 at 13:23)</a>:</h4>
<p>if certain fields are constant but others are not etc.</p>



<a name="174880960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174880960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174880960">(Sep 04 2019 at 13:23)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/48300" target="_blank" title="https://github.com/rust-lang/rust/pull/48300">https://github.com/rust-lang/rust/pull/48300</a></p>



<a name="174881139"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881139" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881139">(Sep 04 2019 at 13:25)</a>:</h4>
<p>OK</p>



<a name="174881268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881268">(Sep 04 2019 at 13:26)</a>:</h4>
<p>I guess not getting a contract early last summer threw a wrench into my plans, ugh</p>



<a name="174881283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881283">(Sep 04 2019 at 13:26)</a>:</h4>
<p>(looking at the date on that PR)</p>



<a name="174881308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881308">(Sep 04 2019 at 13:26)</a>:</h4>
<p>do we think that SROA alone would have an impact on any real use cases?</p>



<a name="174881335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881335">(Sep 04 2019 at 13:26)</a>:</h4>
<p>doubtful but possible if LLVM gets confused on them</p>



<a name="174881351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881351">(Sep 04 2019 at 13:27)</a>:</h4>
<p>oh, you know where it would help? debug mode</p>



<a name="174881366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881366">(Sep 04 2019 at 13:27)</a>:</h4>
<p>since LLVM's wouldn't run</p>



<a name="174881393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881393">(Sep 04 2019 at 13:27)</a>:</h4>
<p>I'm skimming over the notes from the all hands</p>



<a name="174881423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881423">(Sep 04 2019 at 13:27)</a>:</h4>
<p>(and since we preserve debuginfo, we can have it on by default)</p>



<a name="174881523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881523">(Sep 04 2019 at 13:28)</a>:</h4>
<p>seems like "inlining" is another key optimization</p>



<a name="174881529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881529">(Sep 04 2019 at 13:28)</a>:</h4>
<p>that might help with debug mode compilation</p>



<a name="174881575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881575">(Sep 04 2019 at 13:29)</a>:</h4>
<p>I suggest we enable inlining by default with a strict no-branch/no-loop heuristic, and small body otherwise</p>



<a name="174881599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881599">(Sep 04 2019 at 13:29)</a>:</h4>
<p>I guess there are kind of 3 possible goals around MIR optimizations:</p>
<ul>
<li>improving on the perf of <em>optimized</em> code (i.e., doing what LLVM won't do)</li>
<li>improving compilation times for optimized code (and potentially debug code) (i.e., making less LLVM IR)</li>
<li>improving the perf of <em>unoptimized</em> code (i.e., doing what LLVM does, but faster)</li>
</ul>



<a name="174881693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881693">(Sep 04 2019 at 13:30)</a>:</h4>
<p>one exception for branches would be them being based off arguments in a way that would get simplified</p>



<a name="174881708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881708">(Sep 04 2019 at 13:30)</a>:</h4>
<blockquote>
<p>I suggest we enable inlining by default with a strict no-branch/no-loop heuristic, and small body otherwise</p>
</blockquote>
<p>iirc from when <span class="user-mention" data-user-id="125250">@Wesley Wiser</span> was looking into this, we encountered some bugs in the existing inliner, not sure if they've been fixed</p>



<a name="174881717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881717">(Sep 04 2019 at 13:30)</a>:</h4>
<p>heh</p>



<a name="174881728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881728">(Sep 04 2019 at 13:30)</a>:</h4>
<p>also the existing inliner can't preserve debuginfo wrt. closures I think?</p>



<a name="174881736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881736">(Sep 04 2019 at 13:30)</a>:</h4>
<p>obviously, that can be done. just trying to enumerate work items and possible goals.</p>



<a name="174881740"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881740" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881740">(Sep 04 2019 at 13:30)</a>:</h4>
<p>The Inliner needs some (more) work. I did some work on it last year and found a bunch of basic issues with it but it's still doing something bad and causes ICEs if you try to bootstrap with it turned on. (<a href="https://github.com/rust-lang/rust/issues/63802" target="_blank" title="https://github.com/rust-lang/rust/issues/63802">https://github.com/rust-lang/rust/issues/63802</a>)</p>



<a name="174881744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881744">(Sep 04 2019 at 13:31)</a>:</h4>
<p>my PR already can, I think it's reflected in one of the testcase</p>



<a name="174881791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881791">(Sep 04 2019 at 13:31)</a>:</h4>
<p>yeah, so that too is kind of wanting to be integrated with your representation</p>



<a name="174881798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881798">(Sep 04 2019 at 13:31)</a>:</h4>
<p>actually that's another question</p>



<a name="174881800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881800">(Sep 04 2019 at 13:31)</a>:</h4>
<p>can we generate the proper debuginfo for inlined things?</p>



<a name="174881810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881810">(Sep 04 2019 at 13:31)</a>:</h4>
<p>do you think I should focus on MIR? seemes easier than trying to do a million things</p>



<a name="174881881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881881">(Sep 04 2019 at 13:32)</a>:</h4>
<blockquote>
<p>nikomatsakis: can we generate the proper debuginfo for inlined things?</p>
</blockquote>
<p>with my PR, variable debuginfo. but, hmpf</p>



<a name="174881901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881901">(Sep 04 2019 at 13:32)</a>:</h4>
<p>inlining <em>would</em> break location information, unless we can encode it somehow</p>



<a name="174881910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881910">(Sep 04 2019 at 13:32)</a>:</h4>
<blockquote>
<p>do you think I should focus on MIR? seemes easier than trying to do a million things</p>
</blockquote>
<p>what does "focus on MIR" mean</p>



<a name="174881931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881931">(Sep 04 2019 at 13:32)</a>:</h4>
<p>I wonder if <span class="user-mention" data-user-id="124287">@mw</span> has thought about this enough</p>



<a name="174881938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881938">(Sep 04 2019 at 13:33)</a>:</h4>
<blockquote>
<p>inlining <em>would</em> break location information, unless we can encode it somehow</p>
</blockquote>
<p>I mean LLVM does it somehow</p>



<a name="174881957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881957">(Sep 04 2019 at 13:33)</a>:</h4>
<p>focus on MIR vs, say, incremental, or other stuff</p>



<a name="174881961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881961">(Sep 04 2019 at 13:33)</a>:</h4>
<p>at least, when I build with debuginfo on linux, I get stacktraces that are aware of inlining</p>



<a name="174881968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881968">(Sep 04 2019 at 13:33)</a>:</h4>
<p>I see. Yes, I think we should focus on MIR optimizations</p>



<a name="174881984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881984">(Sep 04 2019 at 13:33)</a>:</h4>
<p>(so far my priorities have been pretty out of whack)</p>



<a name="174881991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174881991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174881991">(Sep 04 2019 at 13:33)</a>:</h4>
<p>Certainly I think we should focus on one thing</p>



<a name="174882016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882016">(Sep 04 2019 at 13:33)</a>:</h4>
<p>And I think they're a good choice, in part because I think we have a lot of "almost there" parts, and I think (as you said) there's a lot of pent-up demand</p>



<a name="174882064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882064">(Sep 04 2019 at 13:34)</a>:</h4>
<p>DWARF can represent inlining but I'm not sure how much LLVM exposes. some people have looked into it for macros and it's tricky</p>



<a name="174882087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882087">(Sep 04 2019 at 13:34)</a>:</h4>
<p>one thing I forgot to bring up is I'm thinking more and more about VSDG, since it models so many things so well</p>



<a name="174882123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882123">(Sep 04 2019 at 13:34)</a>:</h4>
<p>and, while I don't want to outright propose it, there is something (R)VSDG does that is kind of hilarious in the historical context of MIR</p>



<a name="174882128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882128">(Sep 04 2019 at 13:35)</a>:</h4>
<p>I'm torn in that I think we should think about using the best representations, but I also don't want to let perfect be the enemy of the good.</p>



<a name="174882148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882148">(Sep 04 2019 at 13:35)</a>:</h4>
<p>(R)VSDG is structured control-flow while MIR is a desugaring of structured control-flow into CFGs</p>



<a name="174882180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882180">(Sep 04 2019 at 13:35)</a>:</h4>
<p>so a discussion we should maybe have at some point is: what would the MIR borrowck look like if it had to work with a structural replacement for CFG?</p>



<a name="174882184"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882184" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882184">(Sep 04 2019 at 13:35)</a>:</h4>
<p>(Especially since we have LLVM to do the "heavy lifting")</p>



<a name="174882245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882245">(Sep 04 2019 at 13:36)</a>:</h4>
<p>Yeah, that also intersects polonius somewhat</p>



<a name="174882272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882272">(Sep 04 2019 at 13:36)</a>:</h4>
<p>I don't think it would be a big issue</p>



<a name="174882278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882278">(Sep 04 2019 at 13:36)</a>:</h4>
<p>(let's say it's still blocky with mutable variables like today, but the overall graph is not an arbitrary CFG)</p>



<a name="174882294"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882294" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882294">(Sep 04 2019 at 13:36)</a>:</h4>
<p>For the most part, the borrow check is a dataflow computation</p>



<a name="174882304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882304">(Sep 04 2019 at 13:36)</a>:</h4>
<p>The main problem MIR was intended to solve was that we had "two sources of truth"</p>



<a name="174882313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882313">(Sep 04 2019 at 13:36)</a>:</h4>
<p>(in the context of the borrow check, I mean)</p>



<a name="174882325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882325">(Sep 04 2019 at 13:37)</a>:</h4>
<p>that is, we kind of "desugared" once for borrow check, and then again for codegen, and they were different</p>



<a name="174882343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882343">(Sep 04 2019 at 13:37)</a>:</h4>
<p>the reason is that you can sort of treat (R)VSDG like a pure term DAG, intern it, etc.</p>



<a name="174882393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882393">(Sep 04 2019 at 13:38)</a>:</h4>
<p>but OTOH we have a bunch of information like <code>SourceInfo</code> that would probably defeat any interning-like MIR storage optimization</p>



<a name="174882439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882439">(Sep 04 2019 at 13:38)</a>:</h4>
<p>I have to admit that this sounds like kind of a big distraction :)</p>



<a name="174882459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882459">(Sep 04 2019 at 13:38)</a>:</h4>
<p>yes, but OTOH one of the reasons I keep doing things other than MIR is because MIR is a huge headache of an IR</p>



<a name="174882460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882460">(Sep 04 2019 at 13:38)</a>:</h4>
<p>i.e., it sounds like you're proposing replacing MIR with something wholly different</p>



<a name="174882506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882506">(Sep 04 2019 at 13:39)</a>:</h4>
<p>well, not necessarily. maybe there is a small change we can make to make it easier to reason about</p>



<a name="174882517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882517">(Sep 04 2019 at 13:39)</a>:</h4>
<p>Hmm. The structures weren't designed for editing, and places are too complex, but other than that?</p>



<a name="174882535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882535">(Sep 04 2019 at 13:39)</a>:</h4>
<p>reasoning about state on a CFG is hard</p>



<a name="174882623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882623">(Sep 04 2019 at 13:40)</a>:</h4>
<p>you have to constantly keep track of what you can trust and how well / under what conditions</p>



<a name="174882627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882627">(Sep 04 2019 at 13:40)</a>:</h4>
<p>What do you mean by "state" here</p>



<a name="174882668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882668">(Sep 04 2019 at 13:40)</a>:</h4>
<p>local variables (plus the implicit global state that e.g. raw pointers and function calls can do arbitrary things to)</p>



<a name="174882730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882730">(Sep 04 2019 at 13:41)</a>:</h4>
<p>but most things on the MIR are arguably pure-ish because Rust lends itself to a style of code which C doesn't</p>



<a name="174882758"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882758" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882758">(Sep 04 2019 at 13:41)</a>:</h4>
<p>I guess kind of how many locals are in SSA form but that has to be detected every single time</p>



<a name="174882815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882815">(Sep 04 2019 at 13:42)</a>:</h4>
<p>anyway it <em>is</em> a distraction given the work already done</p>



<a name="174882865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882865">(Sep 04 2019 at 13:42)</a>:</h4>
<p>(hence me proposing we find time to discuss it without delving into it. guess I failed :P)</p>



<a name="174882923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882923">(Sep 04 2019 at 13:43)</a>:</h4>
<p>yeah, ok, that's what I thought you probably meant.</p>



<a name="174882937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882937">(Sep 04 2019 at 13:43)</a>:</h4>
<p>I could certainly imagine moving towards a more SSA-like setup</p>



<a name="174882978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174882978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174882978">(Sep 04 2019 at 13:44)</a>:</h4>
<p>the logical conclusion of the data dependencies of SSA is encoding state dependencies as linear data dependencies</p>



<a name="174883040"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883040" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883040">(Sep 04 2019 at 13:44)</a>:</h4>
<p>then things are more like functional programs, but without higher-order CPS headaches</p>



<a name="174883060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883060">(Sep 04 2019 at 13:44)</a>:</h4>
<p>linear state &gt; CPS, effectively</p>



<a name="174883113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883113">(Sep 04 2019 at 13:45)</a>:</h4>
<p>still, it feels like we should try to get some working, shipping optimizations -- doing the refactorings we feel are <em>needed</em> for that, but not a lot more. I guess it just seems like we can leave the "heavy lifting" to LLVM for now, but even just doing relatively few, simple optimizations would get us the majority of benefit. And those are not that hard to express on a CFG</p>



<a name="174883133"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883133" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883133">(Sep 04 2019 at 13:45)</a>:</h4>
<p>(but we don't have to do any one thing in particular - I'd rather we find the changes we need <em>keeping</em> the advanced models in mind)</p>



<a name="174883137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883137">(Sep 04 2019 at 13:45)</a>:</h4>
<p>And then we'd have a better idea what our needs are</p>



<a name="174883205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883205">(Sep 04 2019 at 13:46)</a>:</h4>
<p>one thing that is super easy, for example, is (R)VSDG intra-BB</p>



<a name="174883249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883249">(Sep 04 2019 at 13:47)</a>:</h4>
<p>mostly means your statement list is replaced with a chain of stateful statements but anything "shallowly pure" forms more of a DAG around that</p>



<a name="174883261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883261">(Sep 04 2019 at 13:47)</a>:</h4>
<p>which could be a dataflow performance boost, for example</p>



<a name="174883355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883355">(Sep 04 2019 at 13:48)</a>:</h4>
<p>jumping back to implementing and enabling optimizations, to what extent do you think that is blocked on refactoring MIR (and which refactors)</p>



<a name="174883374"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883374" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883374">(Sep 04 2019 at 13:48)</a>:</h4>
<p>ignoring debuginfo</p>



<a name="174883381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883381">(Sep 04 2019 at 13:48)</a>:</h4>
<p>SROA is easy, NRVO is annoying to analyze but also easy once you have the interference predicate</p>



<a name="174883400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883400">(Sep 04 2019 at 13:48)</a>:</h4>
<p>both of  them are ready (minus debuginfo), NRVO may require a heuristic threshold (it's quadratic so a lot of locals slows it down)</p>



<a name="174883438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883438">(Sep 04 2019 at 13:49)</a>:</h4>
<p>I'm thinking of things like:</p>
<ul>
<li>moving away from using indices everywhere, and towards linked lists and/or stable identifiers</li>
<li>refactoring place to (local, proj*)  (in progress)</li>
<li>refactoring place to remove deref and indexing (harder)</li>
</ul>



<a name="174883447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883447">(Sep 04 2019 at 13:49)</a>:</h4>
<p>(the NRVO PR actually has some log of me doing speedups of many orders of magnitude or something just because I was optimizing the term under the quadratic :P)</p>



<a name="174883542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883542">(Sep 04 2019 at 13:50)</a>:</h4>
<blockquote>
<p>SROA is easy, NRVO is annoying to analyze but also easy once you have the interference predicate</p>
</blockquote>
<p>ok -- so they're not blocked on those kinds of changes. To what extent would they <em>benefit</em> from them?</p>



<a name="174883565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883565">(Sep 04 2019 at 13:50)</a>:</h4>
<blockquote>
<p>I'm thinking of things like:</p>
</blockquote>
<p>also, are there other things you would add to this list</p>



<a name="174883577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883577">(Sep 04 2019 at 13:50)</a>:</h4>
<p>a flatter/simplest Place makes it easier to run dataflow, do replacements, etc.</p>



<a name="174883587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883587">(Sep 04 2019 at 13:51)</a>:</h4>
<p>so it would be 1. slightly cleaner implementation 2. may run a bit faster</p>



<a name="174883747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883747">(Sep 04 2019 at 13:52)</a>:</h4>
<blockquote>
<p>also, are there other things you would add to this list</p>
</blockquote>
<p>well, I don't know the full implications of it, wrt <span class="user-mention" data-user-id="120791">@RalfJ</span>'s models, but some sort of "alias" might be interesting</p>



<a name="174883765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883765">(Sep 04 2019 at 13:53)</a>:</h4>
<p>like a raw pointer except not <em>specifically</em> raw or reference or Box</p>



<a name="174883841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883841">(Sep 04 2019 at 13:54)</a>:</h4>
<p>and it would need to be borrowed to actually be turned into something you can access "dynamically"</p>



<a name="174883869"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883869" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883869">(Sep 04 2019 at 13:54)</a>:</h4>
<p>could just as well significantly complicate analysis though so I'm not sure</p>



<a name="174883916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883916">(Sep 04 2019 at 13:54)</a>:</h4>
<blockquote>
<p>well, I don't know the full implications of it, wrt <span class="user-mention silent" data-user-id="120791">RalfJ</span>'s models, but some sort of "alias" might be interesting</p>
</blockquote>
<p>can you elaborate a bit on that? is this intended as an intermediate value when desugaring complex places?</p>



<a name="174883952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883952">(Sep 04 2019 at 13:55)</a>:</h4>
<p>e.g., I've thought about -- as (maybe?) an intermediate step -- convering the MIR after borrowck so that complex places create intermediate values.</p>



<a name="174883990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174883990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174883990">(Sep 04 2019 at 13:55)</a>:</h4>
<p>anyway, we're running up against my quota for this conversation. this was helpful.</p>



<a name="174884038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174884038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174884038">(Sep 04 2019 at 13:56)</a>:</h4>
<p>maybe, yeah</p>



<a name="174884279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/174884279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#174884279">(Sep 04 2019 at 13:58)</a>:</h4>
<p>a really cool thing is eqsat, but it requires something more advanced than CFG+SSA, (R)VSDG being one of the possible choices (you need to be able to share a lot of IR subgraphs)</p>
<p>it lets you run many optimizations on a "pick all the things that you can do, then do them" basis, without forcing an ordering between them, and assuming your rules are sound, it keeps making derivations (and you can have thresholds so you're not generating an infinity of equally useless equivalent programs)</p>



<a name="175765520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/eddyb%20-%20niko%20sync/near/175765520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/eddyb.20-.20niko.20sync.html#175765520">(Sep 15 2019 at 20:50)</a>:</h4>
<p><span class="user-mention" data-user-id="119009">@eddyb</span> what do you mean?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>